package com.yanqu.road.server.cmd.union.war;

import com.yanqu.road.logic.union.UnionWarManger;
import com.yanqu.road.logic.pb.UnionWarPb;
import com.yanqu.road.entity.union.UnionWarDetail;
import com.yanqu.road.entity.union.UserUnionWarMark;
import com.yanqu.road.pb.unionwar.UnionWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.union.UnionWarModule;
import com.yanqu.road.server.manger.union.UnionWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.utils.string.StringUtils;

@Cmd(code = Protocol.S_UNION_WAR_PATRONS_DATA, desc = "商会战门客信息")
public class UnionWarPatronsDataCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        String unionUid = player.getUserInfo().getUnionUid();
        if (StringUtils.isNullOrEmpty(unionUid)) {
            ret = GameErrorCode.E_UNION_NO_JOIN_UNION;
            return;
        }
        UnionWarDetail unionWarDetail = UnionWarMgr.getUnionWarDetail(unionUid);
        boolean isWatchBattle = false;
        UserUnionWarMark userUnionWarMark = player.getModule(UnionWarModule.class).getUserUnionWarMark();
        if (null != userUnionWarMark && userUnionWarMark.getWatchBattleMark() == UnionWarManger.getNowMark()) {
            isWatchBattle = true;
        }
        UnionWarProto.UnionWarDetailMsg.Builder respMsg = UnionWarPb.parseUnionWarDetailMsg(unionWarDetail, isWatchBattle);
        player.sendPacket(Protocol.U_UNION_WAR_PATRONS_DATA, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}


